home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_shs_commiewave.cog < prev    next >
Text File  |  1999-11-15  |  12KB  |  464 lines

  1. # Jones 3D Cog Script
  2. #
  3. # shs_CommieWave.cog
  4. #
  5. # Damn Commies keep showing up.
  6. #
  7. # [JWC]
  8. #
  9. #
  10. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  11. #
  12. # ========================================================================================
  13.  
  14. symbols
  15.  
  16.     message     startup
  17.     message        activated
  18.     message        exited
  19.     message        entered
  20.     message     pulse
  21.     message        damaged
  22.     message        arrivedwpnt
  23.     message        killed
  24.  
  25.     sector        plant0        
  26.     sector        s_SendMessenger
  27.     sector        showSector    #  in the UN
  28.     
  29.     surface     hideSurface    # by the climbing puzzle
  30.    
  31.     AI          AI_Sniper=com_2Hsniper.ai   local
  32.     
  33.  
  34.     # trigger items    
  35.     thing        seal
  36.     thing        bulb
  37.         
  38.     # ice chickens
  39.     thing        ice0      linkid=1      # in BN
  40.     thing        ice1    linkid=1    # in LN
  41.     thing        ice2    linkid=1    # in LN
  42.     
  43.     # wave 1: got seal
  44.     
  45.     int         MESSENGER_COMMIE_INDEX=0    local
  46.  
  47.     thing       commie0        mask=0x409 # this will be the alert commie in LN
  48.     thing       commie1        # in BN
  49.     thing       commie2        # in CT
  50.     thing       commie3        # on roof CT, sniper
  51.     thing       commie4           # in BN
  52.     
  53.     # wave 2: got bulb
  54.     thing       commie5           # in CT
  55.     thing       commie6           # in LN
  56.     
  57.     # wave 3: got bud 
  58.     thing       commie7           # in BN
  59.     thing       commie8           # in CT
  60.     thing       commie9           # in CT
  61.       
  62.     # waypoints
  63.     int            NUM_WAYPOINTS=16    local
  64.     thing        ghost0
  65.     thing        ghost1
  66.     thing        ghost2
  67.     thing        ghost3
  68.     thing        ghost4
  69.     thing        ghost5
  70.     thing        ghost6
  71.     thing        ghost7
  72.     thing        ghost8
  73.     thing        ghost9
  74.     thing        ghost10
  75.     thing        ghost11
  76.     thing        ghost12
  77.     thing        ghost13
  78.     thing        ghost14
  79.     thing        ghost15
  80.         
  81.     int            x                local
  82.     int            y                local
  83.     int            seal=87            local
  84.     int            plantbulb=104     local
  85.     int            plantbud=106     local
  86.     int            commiesAwake=0    local
  87.  
  88.     thing        player            local
  89.         
  90. #.......................SOUNDS.....................
  91.     sound        com_alertline=INXH1010.WAV        local        # "...capitalist stooge" 
  92.     sound         music=mus_shs_gunfight.wav        local
  93.  
  94.  
  95. # ======================VARIABLES===================================================
  96.     int            b_IndyCrossed=0                    local                
  97.     int            b_MessengerSent=0                local
  98.     int            b_CommiesHunting=0                local                
  99.     int            b_MessengerStopped=0            local                
  100.     int            b_WpntsActive=0                    local
  101.  
  102.  
  103.     vector        v_IndyPos                        local
  104.     vector        v_IndyLook                        local
  105.     vector        v_CommiePos                        local
  106.     vector        v_IndyToCommie                    local 
  107.     flex        f_dot                             local
  108.  
  109. # ====================== CONSTANTS ===================================================
  110.  
  111.     int            MESSENGER_FLEE_TO_WAYPOINT=7    local 
  112.     int         MESSENGER_YELL_WAYPOINT=6        local
  113.     int            HUNT_COMMIE_1_INDEX=1            local
  114.     int            HUNT_COMMIE_2_INDEX=4            local
  115.  
  116. # ====================== SUBROUTINES ===================================================
  117.  
  118.     flex        SendMessenger                    local
  119.     flex        WakeupWave1                        local
  120.     flex        ActivateWaypoints                local
  121.     flex        DeactivateWaypoints                local
  122.  
  123. end
  124.  
  125. # ========================================================================================
  126.  
  127. code
  128.  
  129. # ========================================================================================
  130. startup:
  131.     
  132.     player = GetLocalPlayerThing();
  133.     for (x=0; x<=9; x=x+1)
  134.     {
  135.         SetThingFlags(commie0[x], 0x80000); #make invisible
  136.         AISetCutsceneMode(commie0[x]);
  137.     }
  138.     
  139.     // Make sure this guy doesn't move until we want him to.
  140.     // He is the messenger.
  141.     AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "dodge", 0);
  142.     AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "humancombatmove", 0);
  143.     AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "basicfollow", 0);
  144.     AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "circlestrafe", 0);
  145.     AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "listen", 0);
  146.  
  147.     #
  148.     AISetClass(commie3, AI_sniper);
  149.     // Just for testing
  150. //    call ActivateWaypoints;
  151.  
  152.     return;        
  153.                    
  154.  
  155. # ========================================================================================
  156. activated:
  157.     
  158.     # wave 1
  159.     if(GetSenderRef() == seal)
  160.     {    
  161.         call ActivateWaypoints;
  162.         commiesAwake=1;
  163.  
  164.         # Prevent ice chickens from getting underfoot
  165.         if(ice0 != -1) DestroyThing(ice0);
  166.         if(ice1 != -1) DestroyThing(ice1);
  167.         if(ice2 != -1) DestroyThing(ice2);
  168.         
  169.         ice0 = -1;
  170.         ice1 = -1;
  171.         ice2 = -1;
  172.         
  173.     }
  174.     # wave 2
  175.     if(GetSenderRef() == bulb)
  176.     {    
  177.         print("wave2");
  178.         for (x=5; x<=6; x=x+1)
  179.         {
  180.             ClearThingFlags(commie0[x], 0x80000); # make visible
  181.             AIClearCutsceneMode(commie0[x]);     # wake them up
  182.         }
  183.     }
  184.     
  185.     return;
  186.  
  187. # ========================================================================================
  188. // Send messenger if Indy gets to close
  189. entered:    
  190.     if (!b_WpntsActive)
  191.     {
  192.         return;
  193.     }
  194.     if ((GetSenderRef() == s_SendMessenger) && (GetSourceRef() == player))
  195.     {
  196.         if (b_IndyCrossed == 0)
  197.         {
  198.             call SendMessenger;
  199.             b_IndyCrossed = 1;
  200.         }
  201.         return;
  202.     }
  203.     
  204.     # Handles potential ugliness if player is stuck outside
  205.     if ((GetSenderRef() == hideSurface) && (commie3 != -1) && (GetSourceRef() == player))
  206.     {   
  207.         SetThingFlags(commie3, 0x80000);
  208.         return;
  209.     }
  210.     
  211.     if ((GetSenderRef() == showSector) && (GetSourceRef() == player) && (commie3 != -1))
  212.     {
  213.            if (commiesAwake == 1)
  214.         {
  215.             ClearThingFlags(commie3, 0x80000);
  216.             return;
  217.         }
  218.     }
  219.     return;
  220.  
  221.  
  222. # ========================================================================================
  223. exited:
  224.  
  225.     # wave 3
  226.     if((GetSenderRef() == plant0) && (GetInv(player, plantbud) == 1))
  227.     {    
  228.         print("wave3");
  229.         
  230.         for (x=7; x<=9; x=x+1)
  231.         {
  232.             ClearThingFlags(commie0[x], 0x80000); # make visible
  233.             AIClearCutsceneMode(commie0[x]);     # wake them up
  234.         }
  235.         
  236.         AISetInstinctWpntMode(commie7);
  237.         AIEnableInstinct(commie7, "roam", 1);
  238.         AISetInstinctWpntMode(commie9);
  239.         AIEnableInstinct(commie9, "roam", 1);
  240.            return;
  241.     }
  242.     
  243.   return;
  244.  
  245. # ========================================================================================
  246. damaged:
  247.     // If messenger takes damage he heads out immediately
  248.     if (GetSenderRef() == commie0[MESSENGER_COMMIE_INDEX])
  249.     {
  250.         call SendMessenger;
  251.     }
  252.  
  253.     return;
  254.  
  255. # ========================================================================================
  256. killed:
  257.     if (GetSenderRef() == commie0[MESSENGER_COMMIE_INDEX])
  258.     {
  259.         call WakeupWave1;// uh oh
  260.     }
  261.     if (GetSenderRef(ice0) == 1)
  262.     {
  263.         GetSenderRef(ice0) = -1;
  264.     }
  265.     if (GetSenderRef(ice1) == 1)
  266.     {
  267.         GetSenderRef(ice1) = -1;
  268.     }
  269.     if (GetSenderRef(ice2) == 1)
  270.     {
  271.         GetSenderRef(ice2) = -1;
  272.     }
  273.     if (GetSenderRef(commie3) == 1)
  274.     {
  275.         GetSenderRef(commie3) = -1;
  276.     }
  277.     
  278.     return;
  279.  
  280. # ========================================================================================
  281. arrivedwpnt:
  282.     # if messenger reaches the hunt trigger, remaining commies are alerted, and attack
  283.     if((GetSenderRef() == commie0[MESSENGER_COMMIE_INDEX]) && (GetParam(0) == MESSENGER_YELL_WAYPOINT))
  284.     {
  285.         if (b_CommiesHunting == 0)
  286.         {
  287.             //Set some of the commies to patrol, or 'roam' in this case
  288.             
  289.             // Yell to wake up buddies
  290.             PlaySoundThing( com_alertline, commie0[MESSENGER_COMMIE_INDEX], 1.0, 0.1, 30.0, 0);    # wake up buddies
  291.  
  292.             call WakeupWave1;
  293.             
  294.             b_CommiesHunting = 1;
  295.         }
  296.     }
  297.  
  298.     if((GetSenderRef() == commie0[MESSENGER_COMMIE_INDEX]) && (GetParam(0) == MESSENGER_FLEE_TO_WAYPOINT))
  299.     {
  300.         if (!b_MessengerStopped)
  301.         {
  302.             b_MessengerStopped = 1;
  303.             // Stop the messenger.
  304.             AIStopFlee(commie0[MESSENGER_COMMIE_INDEX]);
  305.             AIClearSubMode(commie0[MESSENGER_COMMIE_INDEX], 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION. Was need for FleeToWpnt
  306.             AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "roam", 1);
  307.             AIWpntHuntTarget(commie0[MESSENGER_COMMIE_INDEX], 2.0, 0.0);
  308.         }
  309.     }
  310.     
  311.     return;
  312.  
  313.  
  314. # ========================================================================================
  315. pulse:
  316.  
  317.     // When Indy can see the messenger commie it is time to send the messenger.
  318.     if ( (!b_MessengerSent) && (commie0[MESSENGER_COMMIE_INDEX] != -1))
  319.     {
  320.         v_IndyLook = GetThingLVec(player);
  321.         v_IndyPos = GetThingPos(player);
  322.         v_CommiePos = GetThingPos(commie0[MESSENGER_COMMIE_INDEX]);
  323.  
  324.         v_IndyToCommie = VectorNorm(VectorSub(v_CommiePos, v_IndyPos));
  325.         f_dot = VectorDot(v_IndyToCommie, v_IndyLook);
  326.  
  327.         // Check if Indy is facing toward the commie
  328.         if (f_dot > 0.966)
  329.         {
  330.             // Check for unobstructed Line of Sight between the two 
  331.             if (HasLos(commie0[MESSENGER_COMMIE_INDEX], player))
  332.             {
  333.                 // Stop checking for LOS to player  
  334.                 SetPulse(0.0);
  335.                 
  336. //                Sleep(0.5);
  337. //                PlayVoice(t_commie00[MESSENGER_COMMIE_INDEX], com_alertline, 1.0, 0);    # cuss at jones
  338. //                Sleep(0.5);
  339.  
  340.                 call SendMessenger;
  341.             }
  342.         }
  343.     }
  344.  
  345.     return;
  346.  
  347. # ========================================================================================
  348. SendMessenger:
  349.     if (!b_WpntsActive)
  350.     {
  351.         return;
  352.     }
  353.     if (!b_MessengerSent)
  354.     {
  355.         AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "dodge", 1);
  356.         AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "humancombatmove", 1);
  357.         AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "basicfollow", 1);
  358.         AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "circlestrafe", 1);
  359.         AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "listen", 1);
  360.  
  361.         b_MessengerSent=1;
  362.  
  363.         // Flee to waypoint
  364.         AISetSubMode(commie0[MESSENGER_COMMIE_INDEX], 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION. Required for FleeToWpnt
  365.         AISetInstinctWpntMode(commie0[MESSENGER_COMMIE_INDEX]);
  366.         AIFleeToWpnt(commie0[MESSENGER_COMMIE_INDEX], MESSENGER_FLEE_TO_WAYPOINT);
  367.        
  368.         # Play some music to add drama
  369.         PlaySoundLocal(music, 1.0, 0, 0x0, 0);
  370.         
  371.     }
  372.  
  373.     return;
  374.  
  375.  
  376. # ========================================================================================
  377.  
  378. WakeupWave1:
  379.  
  380.     // wake up everybody now else now.
  381.     // If they were to wake up earlier they might
  382.     // respond to gunfire and get in way of messenger.
  383.     for (x=0; x<=4; x=x+1)
  384.     {
  385.         AIClearCutsceneMode(commie0[x]);     
  386.     }
  387.  
  388.     AIEnableInstinct(commie0[HUNT_COMMIE_1_INDEX], "roam", 1);
  389.     #AIWpntHuntTarget(commie0[HUNT_COMMIE_1_INDEX], 2.0, 0.0);
  390.     AIEnableInstinct(commie0[HUNT_COMMIE_2_INDEX], "roam", 1);
  391.     #AIWpntHuntTarget(commie0[HUNT_COMMIE_2_INDEX], 2.0, 0.0);
  392.  
  393.     return;
  394.  
  395. # ========================================================================================
  396. ActivateWaypoints:
  397.     if (b_WpntsActive)
  398.     {
  399.         return;
  400.     }
  401.     b_WpntsActive = 1;
  402.  
  403.     print("wave1");
  404.     for (x=0; x<=4; x=x+1)
  405.     {
  406.         ClearThingFlags(commie0[x], 0x80000); # make visible
  407.     }
  408.  
  409.     AIClearCutsceneMode(commie0[MESSENGER_COMMIE_INDEX]);     # wake messenger
  410.  
  411.     for (y=0; y < NUM_WAYPOINTS; y=y+1)
  412.     {
  413.         AISetWpnt(Ghost0[y], y);
  414.     }
  415.     AIConnectWpnts(0, 1);
  416.     AIConnectWpnts(1, 2);
  417.     AIConnectWpnts(2, 3);
  418.     AIConnectWpnts(2, 5);
  419.     AIConnectWpnts(3, 4);
  420.     AIConnectWpnts(5, 6);
  421.     AIConnectWpnts(6, 7);
  422.     AIConnectWpnts(7, 8);
  423.     AIConnectWpnts(7, 13);
  424.     AIConnectWpnts(8, 9);
  425.     AIConnectWpnts(8, 11);
  426.     AIConnectWpnts(8, 12);
  427.     AIConnectWpnts(8, 13);
  428.     AIConnectWpnts(9, 10);
  429.     AIConnectWpnts(11, 12);
  430.     AIConnectWpnts(11, 13);
  431.     AIConnectWpnts(13, 14);
  432.     AIConnectWpnts(14, 15);
  433.         
  434.     // Start checking if Indy can see messenger
  435.     SetPulse(0.1);
  436.  
  437.     AISetInstinctWpntMode(commie0[HUNT_COMMIE_1_INDEX]);
  438.     AISetInstinctWpntMode(commie0[HUNT_COMMIE_2_INDEX]);
  439.  
  440.     return;
  441.  
  442.  
  443. # ========================================================================================
  444. DeactivateWaypoints:
  445.  
  446.     if (!b_WpntsActive)
  447.     {
  448.         return;
  449.     }
  450.     b_WpntsActive = 0;
  451.  
  452.     AIEnableInstinct(commie0[MESSENGER_COMMIE_INDEX], "roam", 0); // Don't want them milling about without waypoints
  453.     AIClearInstinctWpntMode(commie0[MESSENGER_COMMIE_INDEX]); 
  454.     AIEnableInstinct(commie0[HUNT_COMMIE_1_INDEX], "roam", 0); // Don't want them milling about without waypoints
  455.     AIClearInstinctWpntMode(commie0[HUNT_COMMIE_1_INDEX]); 
  456.     AIEnableInstinct(commie0[HUNT_COMMIE_2_INDEX], "roam", 0); // Don't want them milling about without waypoints
  457.     AIClearInstinctWpntMode(commie0[HUNT_COMMIE_2_INDEX]); 
  458.  
  459.     return;
  460.  
  461. end
  462.  
  463.